package com.sgb.kjwl.view.ui.adapter.home;

import android.content.Context;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.LeaseEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.MDateUtil;

import java.util.List;

public class LeaseAdapter extends BaseRecycleAdapter<LeaseEntity> {

    private TextView contentView;
    private TextView priceView;

    public LeaseAdapter(Context context, List<LeaseEntity> datas) {
        super(context, R.layout.item_lease, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final LeaseEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        contentView = holder.getItem().findViewById(R.id.content_view);
        priceView = holder.getItem().findViewById(R.id.price_view);
        contentView.setText(entity.getDistrict() + "|" + entity.getBrandName() + "|" + entity.getTypeName() + "|" + entity.getRefreshTime());
        if ("0".equals(entity.getRentalPrice()) || entity.getRentalPrice() == null || "0.00".equals(entity.getRentalPrice())) {
            priceView.setText("面议");
        } else {
            priceView.setText("￥ " + entity.getRentalPrice() + entity.getPriceUnit());
        }

    }

}
